
var app = angular.module('conversionTool', ['smart-table' ]);

app.controller('manageProjectCtrl', [ '$scope', '$http', function($scope, $http) {

	$scope.deleteProject = function(id) {
		$http.post('/rest/project/deleteProject', {
			"id" : id
		}).success(function(data) {

			if (data == true) {
				$scope.initial();
				$scope.msg = "delete success.";
			} else {
				$scope.msg = "server error.";
			}

		}).error(function(data) {
			console.log(data);
		});
	}
	
	$scope.settingProjectID=function(id){
		
		document.getElementById("id").value=id;
		
	}
	
	$scope.itemsByPage=8;
	$scope.projects=[];
	
	$scope.projectsDisplay=[].concat($scope.projects);
	
	$scope.initial=function(){
		
		$http.post('/rest/project/getAllProject').success(function(data) {
			
			$scope.projects=data;
			$scope.projectsDisplay=[].concat($scope.projects);

		}).error(function(data) {
			console.log(data);
		});
		
	}
	
	
	$scope.initial();
	
	
	

} ]);